//
//  StartViewController.m
//  Weikan
//
//  Created by liu yue on 3/9/12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#import "StartViewController.h"
//#import "UIImage+ImagePath.h"

@implementation StartViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView
{
}
*/


// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad
{
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor clearColor];
    if (self.view.frame.size.height > 480)
    {
        starViewImage = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
    }
    else
    {
        starViewImage = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 568)];
    }
    [self.view addSubview:starViewImage];
    [starViewImage release];
    [self adjustPosition:self.interfaceOrientation];
}

- (void)viewDidDisappear:(BOOL)animated
{
    [super viewDidDisappear:animated];
    [starViewImage removeFromSuperview];
}
- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return NO;
}

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
	[self adjustPosition:self.interfaceOrientation];
}

- (void)adjustPosition:(UIInterfaceOrientation)interfaceOrientation
{
    if (UIDeviceOrientationIsLandscape(interfaceOrientation))
    {
        self.view.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
        starViewImage.frame = CGRectMake(0, 0, 480, 320);
         UIImage *img = [[UIImage alloc]initWithContentsOfFile:[[NSBundle mainBundle]pathForResource:@"bg_login_cover.png" ofType:nil]];
        starViewImage.image = img;
        [img release];
    }
    else
    {
        self.view.frame = CGRectMake(0, 0, 320, 480);
        starViewImage.frame = CGRectMake(0, 0, 320, 480);
        UIImage *img = [[UIImage alloc]initWithContentsOfFile:[[NSBundle mainBundle]pathForResource:@"bg_login_cover.png" ofType:nil]];
        starViewImage.image = img;
        [img release];
    }
}
@end
